#include <iostream>
using namespace std;

typedef long long ll;
const int N = 1e6 + 10;
ll n, m;
ll a[N];

ll clac(int num)
{
	ll ret = 0;
	for(int i = 0; i < n; i++)
	{
		if(a[i] > num) ret += a[i] - num;
	}
	
	return ret;
}

int main()
{
	cin >> n >> m;
	
	ll ma = 0;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		ma = max(ma, a[i]);
	}
	
	int left = 0, right = ma;
	while(left < right)
	{
		int mid = left + (right - left + 1)/2;
		
		if(clac(mid) >= m) left = mid;
		else right = mid - 1;
	}
	
	cout << left;
	
	return 0;
}
